FROM openjdk:8-jre-alpine
# 设置工作目录
WORKDIR /app

RUN apk add --no-cache \
    fontconfig \
    ttf-dejavu \
    freetype \
    freetype-dev \
    && fc-cache -fv

# 复制打包好的 jar 文件和配置文件到镜像中
COPY ./target/dynabook-ems-1.2.0.jar ./
COPY ./src/main/resources/application.yml ./

# 设置 JVM 参数环境变量
ENV JAVA_OPTS="-Xms256m -Xmx512m -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=0.0.0.0:5005"

# 暴露应用端口和调试端口
EXPOSE 8103
EXPOSE 5005

# 健康检查
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
  CMD curl -f http://localhost:8103/actuator/health || exit 1

# 启动应用（使用 JSON 格式）
CMD ["java", "-Xms256m", "-Xmx512m",  "-Dfile.encoding=UTF-8", "-Dsun.jnu.encoding=UTF-8","-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=0.0.0.0:5005", "-jar", "dynabook-ems-1.2.0.jar", "--spring.config.location=file:./application.yml"]